#include "chassis.h"
#include <iostream>
#include <fstream>

void Chassis::setId(const std::string& id) {
    this->id = id;
}

void Chassis::setModel(const std::string& model) {
    this->model = model;
}

void Chassis::setWheelbase(const std::string& wheelbase) {
    this->wheelbase = wheelbase;
}

void Chassis::setTrack(const std::string& track) {
    this->track = track;
}

void Chassis::setMinClearance(const std::string& min_clearance) {
    this->min_clearance = min_clearance;
}

void Chassis::setMinTurnRadius(const std::string& min_turn_radius) {
    this->min_turn_radius = min_turn_radius;
}

void Chassis::setDriveType(const std::string& drive_type) {
    this->drive_type = drive_type;
}

void Chassis::setMaxRange(const std::string& max_range) {
    this->max_range = max_range;
}

void Chassis::addTire(const Tire& tire) {
    tires.push_back(tire);
}

void Chassis::print() const {
    std::cout << "底盘ID: " << id << std::endl;
    std::cout << "型号: " << model << std::endl;
    std::cout << "轴距: " << wheelbase << std::endl;
    std::cout << "轮距: " << track << std::endl;
    std::cout << "最小离地间隙: " << min_clearance << std::endl;
    std::cout << "最小转弯半径: " << min_turn_radius << std::endl;
    std::cout << "驱动类型: " << drive_type << std::endl;
    std::cout << "最大续航: " << max_range << std::endl;
    
    std::cout << "轮胎信息:" << std::endl;
    for (const auto& tire : tires) {
        tire.print();
    }
}

void Chassis::save(std::ofstream& out) const {
    out << "底盘ID: " << id << std::endl;
    out << "型号: " << model << std::endl;
    out << "轴距: " << wheelbase << std::endl;
    out << "轮距: " << track << std::endl;
    out << "最小离地间隙: " << min_clearance << std::endl;
    out << "最小转弯半径: " << min_turn_radius << std::endl;
    out << "驱动类型: " << drive_type << std::endl;
    out << "最大续航: " << max_range << std::endl;
    
    out << "轮胎信息:" << std::endl;
    for (const auto& tire : tires) {
        tire.save(out);
    }
}